//
//  Common.swift
//  StoreProject
//
//  Created by CYC on 1998/12/29.
//

// 宏定义

import UIKit
import ESPullToRefresh

// 尺寸
let kScreenWidth = UIScreen.main.bounds.width           // 屏宽
let kScreenHeight = UIScreen.main.bounds.height         // 屏高
let kIsIphoneX = Bool(kScreenHeight > 780.0)            // 是否是刘海屏
let SafeAreaBottomHeight: CGFloat = kIsIphoneX ? 34 : 0 // 底部安全区高度
var kNavHeight = CGFloat(44 + kStatusHeight())          // 导航栏高度
var kTabBarHeight = CGFloat(SafeAreaBottomHeight + 49.0)// 标签栏高度
let kSpaceSize = CGFloat(20.0)                          // 与边缘的距离
let kContentSize = CGFloat(12.0)                        // 容器内与边缘的距离
let kRadiusSizeS = CGFloat(6.0)                         // 圆角大小
let kRadiusSizeL = CGFloat(20.0)                        // 圆角大小
let kLineSize = CGFloat(0.8)                            // 分割线大小

// 颜色
let kMainColor = kHexColor(0xea4e3d)    // 主题色
let kGreenColor = kHexColor(0x4DAA90)   // 绿色-涨
let kRedColor = kHexColor(0xC15465)     // 红色-跌
let kBGColor = kHexColor(0xF8F8F8)      // 背景颜色
let kLineColor = kHexColor(0xC9C9C9)    // 分割线颜色
let kContentColor1 = kHexColor(0xFAF2F2) // 容器颜色
let kContentColor2 = kHexColor(0xF5F5F5) // 容器颜色
let kLabelColor1 = kHexColor(0x000000)  // 文本颜色
let kLabelColor2 = kHexColor(0x888888)  // 文本颜色
let kLabelColor3 = kHexColor(0xBABABA)  // 文本颜色
let kContentColor = kHexColor(0xFFFFFF) // 容器颜色
let kLeftColor = kHexColor(0xa572ff) // 渐变色左边
let kRightColor = kHexColor(0x6659fe) // 渐变色右边



// 对象
let kUserDefault = UserDefaults.standard
let kTodayCom = Calendar.current.dateComponents([.year, .month, .day, .weekday], from: Date())

let kNoticeChange = "kNoticeChange"     // 提醒事件有增删


// 字体
func kRFont(_ size:CGFloat) -> UIFont {
    return UIFont.init(name: "PingFang-SC-Regular", size: size)!
}
func kMFont(_ size:CGFloat) -> UIFont {
    return UIFont.init(name: "PingFang-SC-Medium", size: size)!
}
func kBFont(_ size:CGFloat) -> UIFont {
    return UIFont.boldSystemFont(ofSize: size)
}

// 状态栏高度
func kStatusHeight() -> CGFloat {
    if #available(iOS 13.0, *) {
        return (UIApplication.shared.windows.first?.windowScene?.statusBarManager?.statusBarFrame.size.height)!
    } else {
        return UIApplication.shared.statusBarFrame.size.height
    }
}

// 颜色
func kRGBColor(_ r: CGFloat, _ g: CGFloat, _ b: CGFloat) -> UIColor {
    UIColor.init(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: 1.0)
}
func kRGBAColor(_ r: CGFloat, _ g: CGFloat, _ b: CGFloat, _ a: CGFloat) -> UIColor {
    UIColor.init(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: a)
}
func kHexColor(_ hex : Int) -> UIColor{
    
    return UIColor.init(red: CGFloat((hex & 0xFF0000) >> 16)/255.0,
                        green: CGFloat((hex & 0xFF00) >> 8)/255.0,
                        blue: CGFloat(hex & 0xFF)/255.0,
                        alpha: 1.0)
}



// 销售合约
//        "name": "GovernanceTransferred",
//        "name": "_base",
//        "name": "_fee",
//        "name": "_governance",
//        "name": "_itemToID",
//        "name": "_nftNameInfo",
//        "name": "_nftSellerInfo",
//        "name": "_nftTimeInfo",
//        "name": "_nftTokenInfo",
//        "name": "_nftTypeInfo",
//        "name": "_nftURLInfo",
//        "name": "buy",
//        "name": "cancelSell",
//        "name": "getAllItems",
//        "name": "getItems",
//        "name": "itemNum",
//        "name": "onERC721Received",
//        "name": "sell",
//        "name": "setFee",
//        "name": "setGovernance",
//        "name": "usdtToken",
//        "name": "withdraw",

